package pri.syl.xiaowu.websocket.netty.core.factory;

import pri.syl.xiaowu.websocket.netty.core.factory.constant.SocketAddressConstant;

import java.net.InetSocketAddress;

/**
 * @Author YunLong
 * @Date 2021/7/18 18:55
 * @Description SocketAddressFactory
 **/
public class SocketAddressFactory {
    private SocketAddressFactory() {
    }

    public static InetSocketAddress getSocketAddress(String url) {
        int i = url.indexOf(SocketAddressConstant.SEPARATOR);
        String host = url.substring(0, i);
        int port = Integer.parseInt(url.substring(i + 1));
        return new InetSocketAddress(host, port);
    }
}
